<?php

/**
 * Add your description here
 * 
 * @author 
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

class Default_Model_DbTable_Components extends Zend_Db_Table_Abstract
{
        /**
         * $_name - name of database table
         *
         * @var string
         */
	protected $_name='components';

        /**
         * $_id - this is the primary key of components table
         *        int(10) unsigned         
         *
         * @var int         
         */
	protected $_id='id';

        public function getOrderedComponentsNamesArray() {

            $query = 'select components.id,components.name from components';
            $res=$this->getAdapter()->query($query)->fetchAll();
            $result=array();
            foreach ($res as $row) {
                $result[$row['id']]=$row['name'];
            }

            return $result;
        }

        public function countAllRows() {
            $query = $this->select()->from($this->_name, 'count(*) as all_count');
            $numRows = $this->fetchRow($query);
            return $numRows['all_count'];
        }


}


